<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
	xmlns:cinclude="http://apache.org/cocoon/include/1.0">

	<xsl:param name="q"/>
	<xsl:param name="category"/>

	<xsl:template match="/">
		<select id="search_text">
			<option value="">Select option from list...</option>
			<xsl:apply-templates select="descendant::lst[@name=$category]/int"/>
			<script type="javascript">toggle_options();</script>
		</select>
	</xsl:template>

	<xsl:template match="int">
		<xsl:variable name="reg_era">
			<xsl:if test="$category = 'era_sint'">
				<xsl:choose>
					<xsl:when test="@name = '-5'">
						<xsl:text>Fifth Century B.C.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '-4'">
						<xsl:text>Fourth Century B.C.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '-3'">
						<xsl:text>Third Century B.C.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '-2'">
						<xsl:text>Second Century B.C.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '-1'">
						<xsl:text>First Century B.C.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '1'">
						<xsl:text>First Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '2'">
						<xsl:text>Second Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '3'">
						<xsl:text>Third Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '4'">
						<xsl:text>Fourth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '5'">
						<xsl:text>Fifth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '6'">
						<xsl:text>Sixth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '7'">
						<xsl:text>Seventh Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '8'">
						<xsl:text>Eight Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '9'">
						<xsl:text>Nineth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '10'">
						<xsl:text>Tenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '11'">
						<xsl:text>Eleventh Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '12'">
						<xsl:text>Twelfth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '13'">
						<xsl:text>Thirteenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '14'">
						<xsl:text>Fourteenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '15'">
						<xsl:text>Fifteenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '16'">
						<xsl:text>Sixteenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '17'">
						<xsl:text>Seventeenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '18'">
						<xsl:text>Eighteenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '19'">
						<xsl:text>Nineteenth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '20'">
						<xsl:text>Twentieth Century A.D.</xsl:text>
					</xsl:when>
					<xsl:when test="@name = '21'">
						<xsl:text>Twenty-First Century A.D.</xsl:text>
					</xsl:when>
					<xsl:otherwise>other</xsl:otherwise>
				</xsl:choose>
			</xsl:if>
		</xsl:variable>
		<xsl:choose>
			<xsl:when test="$category = 'era_sint'">
				<xsl:choose>
					<xsl:when test="contains(@name, '-')">
						<option value="\{@name}" class="term">
							<xsl:value-of select="$reg_era"/>
						</option>
					</xsl:when>
					<xsl:otherwise>
						<option value="{@name}" class="term">
							<xsl:value-of select="$reg_era"/>
						</option>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:otherwise>
				<option value="&#x0022;{@name}&#x0022;" class="term">
					<xsl:value-of
						select="concat(translate(substring(@name, 1, 1), 'abcdefghijklmnopqrstuvwxy', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'), substring(@name, 2))"
					/>
				</option>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
</xsl:stylesheet>
